#ifndef _ALLHEAD_H_
#define  _ALLHEAD_H_ 1

#pragma warning(disable:4996) 

#if 0
#include <bios.h>
#include <conio.h>
#include <dos.h>
#include <fcntl.h>
#include <float.h>
#include <io.h>
#include <malloc.h>
#include <math.h>
#include <process.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <sys\types.h>
#include <sys\stat.h>
#include <keys.h>

#define qva(a)         ((a)*(a))

#else


#define swap(a,b) {int c; c=a;a=b;b=c;}
#define swapd(a,b) {double c; c=a;a=b;b=c;}




#include <stdio.h>
#include <errno.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>



#include <sys/types.h>

#define PI      3.14159265358979323846

#ifndef PCplatform 
//#include <sys/param.h>
//#include <sys/un.h>
//#include <netdb.h>
//#include <sys/socket.h>
//#include <sys/time.h>
#else
typedef unsigned char uchar;
typedef unsigned int  uint;
typedef unsigned long ulong;
#include <bios.h>
#include <fcntl.h>
#endif

#include "math.h"
#endif 




#define ESC            27

#define far
#define _fmalloc malloc
#define  halloc(a,b) malloc((a)*(b))
#define _ffree free
#define  hfree free

#define Copyright(name,x,y,z) \static char *name = "\r\n" #x " - Copyright (C) M.Iakobovski " #y " Version " #z " ";


#define ErrMsg printf

typedef void     far * LPVOID    ;

typedef char     far * LPSTR     ;
typedef char     far * LPCHAR    ;
typedef int      far * LPINT     ;
typedef float    far * LPFLOAT   ;
typedef double   far * LPDOUBLE  ;

typedef LPSTR    far * LPLPSTR   ;
typedef LPCHAR   far * LPLPCHAR  ;
typedef LPINT    far * LPLPINT   ;
typedef LPFLOAT  far * LPLPFLOAT ;
typedef LPDOUBLE far * LPLPDOUBLE;
typedef LPVOID   far * LPLPVOID;
typedef LPLPFLOAT far* LPLPLPFLOAT;
typedef LPLPCHAR far* LPLPLPCHAR;
typedef LPLPINT  far* LPLPLPINT;
typedef LPLPINT far* LPLPLPINT;
typedef LPLPVOID far* LPLPLPVOID;

#ifndef TRG_DEF
#define TRG_DEF 
typedef int TRG[3];
typedef TRG  * LPTRG;
#endif

#define MulDiv(a,b,c)  (int)( ((long)(a)) *(long)(b) / (long)(c) )
#define minab(a,b)     (((a) > (b)) ? (b) : (a))
#define maxab(a,b)     (((a) > (b)) ? (a) : (b))
#define qva(a)         ((a) * (a))

#define kbaddr   ((LPINT)0x00400017)
#define kbstat   (int)(*kbaddr)
#define CLEKB    *kbaddr = 0;

#define S_SCROLL (int)0x10
#define S_CAPS   (int)0x40

#define R_SHIFT  (int)0x01
#define L_SHIFT  (int)0x02

#define R_CTRL   (int)0x04
#define L_CTRL   (int)agr(0x01,0x04)

#define R_ALT    (int)0x08
#define L_ALT    (int)agr(0x02,0x08)

#define KBBREAK  (kbstat & S_SCROLL)
#define KBRE     if(kbstat)exit(1);
#define KBR      if(kbstat)


int jak_reading(int msgsock, LPSTR msg);
int jak_writing(int sock, int size, LPSTR msg);
int getline (FILE *f,LPSTR str, int n);
long filesize(FILE *f);
/*
int    far   *alloc_int_mas_n1     (int n1);
char   far   *alloc_char_mas_n1    (int n1);
LPFLOAT       alloc_float_mas_n1   (int n1);
double far   *alloc_double_mas_n1  (int n1);

int    far  **alloc_int_mas_n1_n2  (int n1, int n2);
char   far  **alloc_char_mas_n1_n2 (int n1, int n2);
float  far  **alloc_float_mas_n1_n2(int n1, int n2);
double far  **alloc_double_mas_n1_n2(int n1, int n2);

int   far ***alloc_int_mas_point2_n1(int n1);
//float far ***alloc_float_mas_n1_n2_n3(int n1, int n2, int n3);
float far  **alloc_float_mas_point1_n1(int n1);
*/
void free_mas_n1_n2(LPLPVOID *p,int n1,int n2);
void free_mas_n1_n2_n3(LPLPLPVOID *p,int n1,int n2,int n3);


LPCHAR   alloc_char_mas_n1    (int n1);
LPINT    alloc_int_mas_n1     (int n1);
LPFLOAT  alloc_float_mas_n1   (int n1);
LPDOUBLE alloc_double_mas_n1  (int n1);

LPLPCHAR   alloc_char_mas_n1_n2 (int n1, int n2);
LPLPINT    alloc_int_mas_n1_n2  (int n1, int n2);
LPLPFLOAT  alloc_float_mas_n1_n2(int n1, int n2);
LPLPDOUBLE alloc_double_mas_n1_n2(int n1, int n2);

LPLPLPCHAR   alloc_char_mas_n1_n2_n3(int n1, int n2, int n3);
LPLPLPINT   alloc_int_mas_n1_n2_n3(int n1, int n2, int n3);
LPLPLPFLOAT  alloc_float_mas_n1_n2_n3(int n1, int n2, int n3);
//LPLPLPDOUBLE alloc_double_mas_n1_n2_n3(int n1, int n2, int n3);

#endif
